package org.nanotek.persistence;

import java.util.List;
import java.util.Map;

import javax.persistence.Query;
import javax.persistence.StoredProcedureQuery;
import javax.persistence.criteria.CriteriaDelete;
import javax.persistence.criteria.CriteriaUpdate;

import org.nanotek.Base;

public interface DAO <T extends Base<?>> {
	
	public void setBaseClass(Class<T> baseClass)  throws DAOException;
	
	public void clear()  throws DAOException;

	public boolean contains(T entity)  throws DAOException;

	public Query createNamedQuery(String name)  throws DAOException;

	public StoredProcedureQuery createNamedStoredProcedureQuery(String name)  throws DAOException;

	public Query createNativeQuery(String sqlString)  throws DAOException;

	public Query createNativeQuery(String sqlString,  Class<T> resultClass)  throws DAOException;

	public Query createNativeQuery(String sqlString, String resultSetMapping)  throws DAOException;

	public Query createQuery(String qlString) throws DAOException;

//	public <T> TypedQuery<T> createQuery(CriteriaQuery<T> criteriaQuery);

	public Query createQuery(CriteriaUpdate<T> updateQuery) throws DAOException;

	public Query createQuery(CriteriaDelete<T> deleteQuery) throws DAOException;

//	public <T> TypedQuery<T> createQuery(String qlString, Class<T> resultClass);

	public StoredProcedureQuery createStoredProcedureQuery(String procedureName, String... resultSetMappings) throws DAOException;

	public void detach(T entity) throws DAOException;

	public T find(Object primaryKey) throws DAOException;
//	public <T> T find(Class<T> entityClass, Object primaryKey);

	public T find(Object primaryKey, Map<String, Object> properties) throws DAOException;

//	public <T> T find(Class<T> entityClass, Object primaryKey,
//			Map<String, Object> properties);

//	
//	public <T> T find(Class<T> entityClass, Object primaryKey,
//			LockModeType lockMode);

//	
//	public <T> T find(Class<T> entityClass, Object primaryKey,
//			LockModeType lockMode, Map<String, Object> properties);

	public void flush() throws DAOException;

	public T merge(T entity) throws DAOException;

	public void persist(T entity) throws DAOException;

	public void refresh(T entity) throws DAOException;

	public void refresh(Map<String, Object> properties) throws DAOException;

	
//	public void refresh(Object entity, LockModeType lockMode);
	
//	public void refresh(Object entity, LockModeType lockMode,
//			Map<String, Object> properties);

	public void remove(T entity) throws DAOException;
	
	/**
	 * 
	 * @return
	 */
	
	public Long countRecords() throws DAOException;
	public List<T> loadAll() throws DAOException; 
	public List<T> listRecords(Integer firstResult , Integer maxResults) throws DAOException;
	
}